package com.zlsy.thread.singleton;

import java.util.HashMap;
import java.util.Map;

/**
 * @author zhouliang
 * @date 2020/5/11 16:47
 */
public enum Singleton8 {
    /**
     * 单例模式-枚举
     */
    INSTANCE;

    private Map<String, Test> map = new HashMap<>();

    Singleton8() {
        Test test1 = new Test1();
        Test test2 = new Test2();
        map.put("a", test1);
        map.put("b", test2);
    }

    public Test get(String key) {
        return map.get(key);
    }
}
